package fem2.element.crack_sda;

import inf.jlinalg.IMatrix;
import fem2.MaterialModel;
import fem2.MeshPart;
import fem2.material.cohesive_law.CohesiveLaw;

public class SKONConstantJumpElement extends KOSConstantJumpElement {

	public SKONConstantJumpElement(MeshPart mp, MaterialModel mm, CohesiveLaw cohesiveLaw) {
		super(mp, mm, cohesiveLaw);
	}

	@Override
	protected void computeProjectionOperator(MeshPart mp, IMatrix g, double... xi) {
		int dim = mp.getDimension();
		double coeff = -crackMeasure / elementMeasure;
		if (dim == 2) {
			g.set(0, 0, coeff * normal[0]);
			g.set(1, 1, coeff * normal[1]);
			g.set(2, 0, coeff * normal[1]);
			g.set(2, 1, coeff * normal[0]);
		} else if (dim == 3) {
			g.set(0, 0, coeff * normal[0]);
			g.set(1, 1, coeff * normal[1]);
			g.set(2, 2, coeff * normal[2]);

			g.set(3, 0, coeff * normal[1]);
			g.set(3, 1, coeff * normal[0]);

			g.set(4, 1, coeff * normal[2]);
			g.set(4, 2, coeff * normal[1]);

			g.set(5, 0, coeff * normal[2]);
			g.set(5, 2, coeff * normal[0]);
		}
	}

}
